python/xc: do not crash xend if /proc/xen/privcmd cannot be opened
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 22 Jun 2010 15:00:08 +0000 (16:00 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 22 Jun 2010 15:00:08 +0000 (16:00 +0100)
If /proc/xen/privcmd cannot be opened,
start xend occurs Segmentation fault.
Add check to fix it.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
tools/python/xen/lowlevel/xc/xc.c

index a7286c4e85270ffcfab77150e82d8b74f02cd411..13704249b527f9207a1cb3af9c917611b9b83020 100644 (file)
@@ -72,7 +72,8 @@ static PyObject *pyxc_error_to_exception(xc_interface *xch)
     else
         pyerr = Py_BuildValue("(is)", err->code, desc);
 
-    xc_clear_last_error(xch);
+    if (xch)
+        xc_clear_last_error(xch);
 
     if ( pyerr != NULL )
     {